#ifndef _COMM_PIPE_H_
#define _COMM_PIPE_H_

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "comm.h"


class comm_pipe:public comm
{
	public:
		comm_pipe();
		~comm_pipe();
		
		int open(void * comm_para);
		int write(char * p_data, size_t length);
		int read(char * p_data, size_t req_len);
		int read_a_line(char * p_data, size_t req_len);
		int close();
		int flush();		
		
	private:
		char *mFIFO_PATH;
		char *mFIFO_PATH_RET;
		void _read_thread();
		int check_line(char *buf);
		static void *read_thread(void *thread_para);
		pthread_t mReadThread;
		int mPipeRdHandle;
		int mPipeWrHandle;
		fd_set mRds;

};

#endif
